package sword_to_1;

public class LeeCode_14_1 {
    public static void main(String[] args) {
        System.out.println(cuttingRope(6));
    }
    private static int cuttingRope(int n) {
        if (n == 3)
            return 2;
        if (n == 2)
            return 1;
        int ans = 1;
        int c = n / 3;
        int yu = n % 3;
        if (yu == 1){
            for (int i = 0; i < c - 1; i++) {
                ans *= 3;
            }
            ans *= 4;
        }else {
            for (int i = 0; i < c; i++) {
                ans *= 3;
            }
            ans *= yu == 0 ? 1 : yu;
        }
        return ans;
    }
}
